<script setup lang="ts">
import { useRouter } from 'vue-router'
import useAdInfo from '@renderer/store/adStore'
import { ref } from 'vue'
import useConfig from '@renderer/store/config'

const router = useRouter()
const adInfo = useAdInfo()
const configObj = ref()
const configStore = useConfig()

// 监听菜单点击跳转设置页面
window.api.settings((name) => {
  router.push({ name })
})
// 获取定位信息，如果没有则跳转设置页面手动设置
window.api.address((val) => {
  if (!val || !adInfo.add.id) {
    router.push('/settings')
    return
  }
  !adInfo.add.id && adInfo.setInfo(val)
})
// 获取配置信息
window.api.config(config => {
  configObj.value = config
  config && configStore.setConfig(config)
})
</script>

<template>
  <div><router-view /></div>
</template>
<style lang="scss">
#app {
  border-radius: 8px;
  overflow: hidden;
}
</style>
